﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuestionnaireSend.aspx.cs" Inherits="ZX.WebApp.TR.QuestionnaireSend" EnableEventValidation="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <%--<script src="../Scripts/CombinButton.js" type="text/javascript"></script>--%>
    <style type="text/css">
        body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="width:550px; height:100%;">
            <tr>
                <td align="center" colspan="4" style="height:40px;font-weight:bold;">发送问卷</td>
            </tr>
            <tr>
                <td style="width:80px; text-align:right;">问卷名称</td>
                <td><asp:TextBox ID="txtName" runat="server" Enabled="false"></asp:TextBox></td>
                <td>发起部门</td>
                <td><asp:TextBox ID="txtBm" runat="server" Enabled="false"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width:80px; text-align:right;">开始时间</td>
                <td><asp:TextBox ID="txtSTime" runat="server" Enabled="false"></asp:TextBox></td>
                <td>结束时间</td>
                <td><asp:TextBox ID="txtETime" runat="server" Enabled="false"></asp:TextBox></td>
            </tr>
            <tr height="40px" valign="bottom">
                <td style="width:80px; text-align:right;">所属部门</td>
                <td colspan="3">
                    <asp:DropDownList ID="drpDept" runat="server" Width="155px" 
                        AppendDataBoundItems="true" AutoPostBack="True" 
                        onselectedindexchanged="drpDept_SelectedIndexChanged">
                        <asp:ListItem Value="00">--选择部门过滤--</asp:ListItem>
                        <asp:ListItem Value="11">集团总部</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td style="width:80px; text-align:right;">人员列表</td>
                <td><asp:ListBox ID="lstBoxSubject" runat="server" Height="230px" Width="155px"></asp:ListBox></td>
                <td>
                    <button id="add" type="button" style="width:55px;" >—></button><br /><br />
                    <button id="remove" type="button" style="width:55px;" ><—</button><br /><br />
                    <button id="add_all" type="button" style="width:55px;">—>></button><br /><br />
                    <button id="remove_all" type="button" style="width:55px;"><<—</button>
                </td>
                <td><asp:ListBox ID="lstBoxResult" runat="server" Height="230px" Width="155px"></asp:ListBox></td>
            </tr>
            <asp:HiddenField ID="hiddenId" runat="server" />
            <asp:HiddenField ID="hiddenDId" runat="server" />
        </table>
    </div>
    </form>
</body>
<script type="text/javascript">
    $(function () {
        //移到右边
        $('#add').click(function () {
            //获取选中的选项，删除并追加给对方
            $('#lstBoxSubject option:selected').appendTo('#lstBoxResult');
        });
        //移到左边
        $('#remove').click(function () {
            $('#lstBoxResult option:selected').appendTo('#lstBoxSubject');
        });
        //全部移到右边
        $('#add_all').click(function () {
            //获取全部的选项,删除并追加给对方
            $('#lstBoxSubject option').appendTo('#lstBoxResult');
        });
        //全部移到左边
        $('#remove_all').click(function () {
            $('#lstBoxResult option').appendTo('#lstBoxSubject');
        });
        //双击选项
        $('#lstBoxSubject').dblclick(function () { //绑定双击事件
            //获取全部的选项,删除并追加给对方
            $("option:selected", this).appendTo('#lstBoxResult'); //追加给对方
        });
        //双击选项
        $('#lstBoxResult').dblclick(function () {
            $("option:selected", this).appendTo('#lstBoxSubject');
        });
    });

    function Save() {
        var objsel = document.getElementById("lstBoxResult");
        var listid="";var allid = "";var alldId = "";
        for (var i = 0; i<objsel.options.length; i++) {
            customOptions = document.createElement("OPTION");
            if (objsel.options[i].value == "11") {
                allid = objsel.options[i].value + ",";
                break;
            } else if (objsel.options[i].value == "22") {
                alldId = document.getElementById("hiddenDId").value + ",";
                break;
            }
            else {
                listid += objsel.options[i].value + ",";
            }
        }
        var QId = document.getElementById("hiddenId").value;
        var url = "";
        if (allid != "") {
            url = "../Extend/AjaxData/DataProcessin.aspx?action=Save&entity=TrSendQuestion&id=" + QId + "&ids=" + allid;
        } else if (alldId != "") {
            url = "../Extend/AjaxData/DataProcessin.aspx?action=Save&entity=TrSendQuestion&id=" + QId + "&ids=" + alldId;
        } else {
            url = "../Extend/AjaxData/DataProcessin.aspx?action=Save&entity=TrSendQuestion&id=" + QId + "&ids=" + listid;
        }
        YAHOO.util.Connect.asyncRequest('POST', url, {
            success: function (res) {
                var inventory;
                try {
                    inventory = res.responseText;
                    if (inventory == 1) {
                        alert("发送成功!");
                        parent.closeWin();
                    } else {
                        alert("发送失败!");
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("读取菜单数据错误：" + error.statusText);
            }
        }, null);
    }
</script>
</html>
